﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace zuoye5_e3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string file1 = "";
        string file2 = "";
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog(); 
            dialog.Multiselect = true;
            dialog.Title = "请选择文件";
            dialog.Filter = "所有文件(*.*)|*.*";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                 file1 = dialog.FileName;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Multiselect = true;
            dialog.Title = "请选择文件";
            dialog.Filter = "所有文件(*.*)|*.*";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                 file2 = dialog.FileName;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string Txt1 = File.ReadAllText(file1);
            string Txt2 = File.ReadAllText(file2);
            string folderPath = @".\data";
            string resPath = @".\data\res.txt";
            string Txt3 = Txt1+"/n"+Txt2;
            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }
            if (!File.Exists(resPath))
            {
                using (StreamWriter sw = new StreamWriter(resPath))
                {
                    sw.WriteLine(Txt3);
                }
            }
            else
            {
                File.WriteAllText(resPath, Txt3);
            }
        }
    }
}
